package com.bitnpulse.dev2.jjh.engstudybook_free.page;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bitnpulse.dev2.jjh.engstudybook_free.R;
import com.bitnpulse.dev2.jjh.engstudybook_free.common.Util;
import com.google.android.youtube.player.YouTubePlayer;
import com.google.android.youtube.player.YouTubePlayer.Provider;
import com.google.android.youtube.player.YouTubePlayerView;

public class HelpPage extends YouTubeFailureRecoveryActivity {

	int mMode;
	
	LinearLayout mhelp_imagelayout;
	ImageView mhelp_image;
	
	TextView mhelp_title;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		
		setContentView(R.layout.helppage_layout);
		
		Intent intent = getIntent();
		
		mMode = intent.getIntExtra("MODE", 0);
		
		YouTubePlayerView youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view);
		youTubeView.initialize(Util.id, this);
		
		mhelp_imagelayout = (LinearLayout)findViewById(R.id.help_imagelayout);
		
		mhelp_image = (ImageView)findViewById(R.id.help_image);
		
		mhelp_title = (TextView)findViewById(R.id.help_title);
		
		switch (mMode) {
			case 0: //ContentsActivity.MODE_LISTEN:
				mhelp_title.setText(R.string.title_help01);
				mhelp_image.setBackgroundResource(R.drawable.manual1);
				break;
		 	case 1: //ContentsActivity.MODE_READ:
				mhelp_title.setText(R.string.title_help02);
				mhelp_image.setBackgroundResource(R.drawable.manual2);
				break;
			case 2://ContentsActivity.MODE_REPEAT:
		    case 3://ContentsActivity.MODE_REPEAT_PLAY:
		    case 5://ContentsActivity.MODE_COMPARE_PLAY:
				mhelp_title.setText(R.string.title_help03);
				mhelp_image.setBackgroundResource(R.drawable.manual3);
				break;
		    case 4://ContentsActivity.MODE_WRIT:
				mhelp_title.setText(R.string.title_help04);
				mhelp_image.setBackgroundResource(R.drawable.manual4);
				break;

		}
		
		
//		mhelp_imagelayout.ad
		
	}
	
	
	  @Override
	  public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,
	      boolean wasRestored) {
		    if (!wasRestored) {
		      
		      switch (mMode) {
			      case 0: //ContentsActivity.MODE_LISTEN:
			    	    player.cueVideo("xhCKTOItpvI");
					break;
			      case 1: //ContentsActivity.MODE_READ:
			    	    player.cueVideo("J96koyU_J_Y");
					break;
			      case 2://ContentsActivity.MODE_REPEAT:
			      case 3://ContentsActivity.MODE_REPEAT_PLAY:
			      case 5://ContentsActivity.MODE_COMPARE_PLAY:
			    	    player.cueVideo("5zkdldfC9NU");
					break;
			      case 4://ContentsActivity.MODE_WRIT:
			    	    player.cueVideo("viYAev7y9po");
			    	break;
					
		
			}
	      
	    }
	  }

	@Override
	protected Provider getYouTubePlayerProvider() {
		// TODO Auto-generated method stub
		return null;
	}
	
}
